import request from '@/config/axios'
import type { PrintTemplateItem } from './types'

export const getPrintTemplateItemsListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/print-template-items', params })
}

export const createPrintTemplateItemsApi = (
  data: Partial<PrintTemplateItem>
): Promise<IResponse> => {
  return request.post({ url: '/print-template-items', data })
}

export const batchCreatePrintTemplateItemsApi = (
  data: Partial<{ print_template_id: string; items: PrintTemplateItem[] }>
): Promise<IResponse> => {
  return request.post({ url: '/print-template-items/batch', data })
}

export const updatePrintTemplateItemsApi = (
  id: string,
  data: Partial<PrintTemplateItem>
): Promise<IResponse> => {
  return request.put({ url: `/print-template-items/id/${id}`, data })
}

export const getPrintTemplateItemsDetailApi = (
  id: string
): Promise<IResponse<PrintTemplateItem>> => {
  return request.get({ url: `/print-template-items/id/${id}` })
}

export const delPrintTemplateItemsListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/print-template-items/id/${ids[0]}` })
}
